<?php

namespace app\common\model;


use think\Model;

class ActivityRewardModel extends Model {

    // 挂件时长
    const PROPS_DURATION_CATE = [
        3  => '3天',
        7  => '7天',
        30 => '一个月',
        0  => '永久',
    ];


    public static function getPropsDurationTextAttr($value, $data) {
        return isset(self::PROPS_DURATION_CATE[$data['props_duration']]) ? self::PROPS_DURATION_CATE[$data['props_duration']] : '';
    }

    // 挂件关联
    public function props() {
        return $this->hasOne(PropsModel::class, 'id', 'props_id');
    }

    // 礼物关联
    public function gift() {
        return $this->hasOne(GiftModel::class, 'id', 'gift_id');
    }

}